package me.wangcai.onlinechat.model;

import com.google.gson.annotations.Expose;
import lombok.AllArgsConstructor;
import lombok.Data;
import me.wangcai.onlinechat.manager.UserManager;

import javax.servlet.http.HttpSession;
import java.io.Serializable;

@Data
public class User implements Serializable {
    private String username;

    public User(String username,HttpSession httpSession){
        this.username = username;
        UserManager.getUserManager().getUserHttpSession().put(this,httpSession);
    }

    public void offline(){
        UserManager.getUserManager().getUserHttpSession().get(this).removeAttribute("user");
    }
}
